import Vue from 'vue'
import Router from 'vue-router'
import index from '@/components/index'
import myindex from '@/components/myindex'
import myreg from '@/components/myreg'
import mylogin from '@/components/mylogin'
import myhome from '@/components/myhome'
import showcate from '@/components/showcate'
import addcourse from '@/components/addcourse'
import courselist from '@/components/courselist'
import coursedetail from '@/components/coursedetail'
import ant_reg from '@/components/ant_reg'
import putuser from '@/components/putuser'
import updatauser from '@/components/updatauser'
import myback from '@/components/myback'
import logins from '@/components/logins'
import zhuce from '@/components/zhuce'
import check from '@/components/check'
import cha from '@/components/cha'
import mycates from '@/components/mycates'
import gong from '@/components/gong'
import shoecate from '@/components/shoecate'
import get_cate from '@/components/get_cate'
import Addworkorder from '@/components/Addworkorder'
import show from '@/components/show'
Vue.use(Router)

var routes = [
        {
          path:'/show',
          name:'show',
          component:show
        },
        {
          path:'/addwork',
          name:'Addworkorder',
          component:Addworkorder
        },
        {
          path:'/get_cate',
          name:'get_cate',
          component:get_cate
        },
        {
          path:'/gong',
          name:'gong',
          component:gong
        },
        {
          path:'/shoecate',
          name:'shoecate',
          component:shoecate
        },
        {
          path:'/mycates',
          name:'mycates',
          component:mycates
        },
        {
          path:'/zhuce',
          name:'zhuce',
          component:zhuce
        },
        {
          path:'/cha',
          name:'cha',
          component:cha
        },
        {
          path:'/check',
          name:'check',
          component:check
        },
        {
          path:'/',
          name:'myindex',
          component:myindex
        },
        {
          path:'/logins',
          name:'logins',
          component:logins
        },
        {
          path:'/myback',
          name:'myback',
          component:myback
        },
        {
          path:'/putuser',
          name:'putuser',
          component:putuser
        },
        {
          path:'/updatauser',
          name:'updatauser',
          component:updatauser
        },
        {
          path:'/myindex',
          name:'myindex',
          component:myindex
        },
        {
          path:'/myreg',
          name:'myreg',
          component:myreg
        },
        {
          path:'/courselist',
          name:'courselist',
          component:courselist
        },
        {
          path:'/coursedetail',
          name:'coursedetail',
          component:coursedetail
        },
        {
          path:'/addcourse',
          name:'addcourse',
          component:addcourse
        },
        {
          path:'/mylogin',
          name:'mylogin',
          component:mylogin
        },
        {
          path:'/showcate',
          name:'showcate',
          component:showcate
        },
        {
          path:'/ant_reg',
          name:'ant_reg',
          component:ant_reg
        },
        {
          path:'/myhome',
          name:'myhome',
          component:myhome,
          //拦截器使用
          beforeEnter:(to,from,next) => {

              if(localStorage.getItem("username")){
                  console.log('登录了');
                  next();
              }else{
                next('/mylogin');
              }

          }
        }
        
]

export default new Router({
  routes:routes,
  mode:'history'   /*hash*/
})
